package main

import (
	"GetMailCode/handler"
	"github.com/micro/go-micro"
	"github.com/micro/go-micro/util/log"
	"github.com/micro/go-plugins/registry/consul"

	GetMailCode "GetMailCode/proto/getMailCode"
)

func main() {
	// 把微服务注册到consul上
	consulReg := consul.NewRegistry()

	// New Service
	service := micro.NewService(
		micro.Name("getMailCode"),
		micro.Address("127.0.0.1:12342"),
		micro.Registry(consulReg),
		micro.Version("latest"),
	)

	// Register Handler
	GetMailCode.RegisterGetMailCodeHandler(service.Server(), new(handler.GetMailCode))

	// Run service
	if err := service.Run(); err != nil {
		log.Fatal(err)
	}
}
